package com.lsl.endworkvol.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class OprationResultController {

    @RequestMapping(path = "/volunteer/warning/checkout_failed", method = RequestMethod.GET)
    public ModelAndView checkOutFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "签到失败，请稍后重试或联系管理员");
        modelAndView.addObject("info", "请检查您是否已经错过了签到时间，或者稍后重新尝试，如有疑问请联系活动负责人或管理员");
        modelAndView.addObject("returnLink", "/volunteer/activities_list_page");
        modelAndView.addObject("returnButtonText", "返回活动列表");
        return modelAndView;
    }

    @RequestMapping(path = "/volunteer/message/checkout_success", method = RequestMethod.GET)
    public ModelAndView checkOutSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "签到成功");
        modelAndView.addObject("returnLink", "/volunteer/activities_list_page");
        modelAndView.addObject("returnButtonText", "前往活动列表查看");
        return modelAndView;
    }

    @RequestMapping(path = "/volunteer/warning/exit_activity_failed", method = RequestMethod.GET)
    public ModelAndView exitActivityFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "退出活动失败");
        modelAndView.addObject("info", "请检查活动报名是否已经结束，已经结束报名的活动无法退出，如有疑问请联系活动负责人或管理员");
        modelAndView.addObject("returnLink", "/volunteer/activities_list_page");
        modelAndView.addObject("returnButtonText", "返回活动列表");
        return modelAndView;
    }

    @RequestMapping(path = "/volunteer/message/exit_activity_success", method = RequestMethod.GET)
    public ModelAndView exitActivitySuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "退出活动成功");
        modelAndView.addObject("returnLink", "/volunteer/activities_list_page");
        modelAndView.addObject("returnButtonText", "前往活动列表查看");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/warning/checkout_failed", method = RequestMethod.GET)
    public ModelAndView checkoutFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "帮助签到失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系系统管理员和技术人员");
        modelAndView.addObject("returnLink", "/leader/activities_checkout_list_page");
        modelAndView.addObject("returnButtonText", "返回签到管理列表");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/message/checkout_success", method = RequestMethod.GET)
    public ModelAndView checkoutSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "帮助签到成功");
        modelAndView.addObject("returnLink", "/leader/activities_checkout_list_page");
        modelAndView.addObject("returnButtonText", "前往签到管理列表查看");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/warning/kick_out_failed", method = RequestMethod.GET)
    public ModelAndView kickOutFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "将志愿者移出活动失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系系统管理员和技术人员");
        modelAndView.addObject("returnLink", "/leader/activities_checkout_list_page");
        modelAndView.addObject("returnButtonText", "返回签到管理列表");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/message/kick_out_success", method = RequestMethod.GET)
    public ModelAndView kickOutSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "将志愿者移出活动成功");
        modelAndView.addObject("returnLink", "/leader/activities_checkout_list_page");
        modelAndView.addObject("returnButtonText", "前往签到管理列表查看");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/warning/activity_score_failed", method = RequestMethod.GET)
    public ModelAndView activityScoreFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "活动评分失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系系统管理员和技术人员");
        modelAndView.addObject("returnLink", "/leader/activities_grade_page");
        modelAndView.addObject("returnButtonText", "返回评分管理列表");
        return modelAndView;
    }

    @RequestMapping(path = "/leader/message/activity_score_success", method = RequestMethod.GET)
    public ModelAndView activityScoreSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "活动评分成功");
        modelAndView.addObject("returnLink", "/leader/activities_grade_page");
        modelAndView.addObject("returnButtonText", "前往评分管理列表查看");
        return modelAndView;
    }

    @RequestMapping(path = {
        "admin/warning/info_edit_failed", 
        "leader/warning/info_edit_failed",
        "volunteer/warning/info_edit_failed"
    },
    method = RequestMethod.GET
)
    public ModelAndView infoEditFailed(ModelAndView modelAndView, HttpServletRequest request) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "信息修改失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        if (request.getSession().getAttribute("role").toString().equals("admin")) {
            modelAndView.addObject("returnLink", "/admin/myinfo_page");
        } else if (request.getSession().getAttribute("role").toString().equals("leader")) {
            modelAndView.addObject("returnLink", "/leader/myinfo_page");
        } else if (request.getSession().getAttribute("role").toString().equals("volunteer")) {
            modelAndView.addObject("returnLink", "/volunteer/myinfo_page");
        }
        modelAndView.addObject("returnButtonText", "返回个人信息页面");
        return modelAndView;
    }
    
    @RequestMapping(path = {
            "admin/warning/info_edit_failed_pwd_wrong", 
            "leader/warning/info_edit_failed_pwd_wrong",
            "volunteer/warning/info_edit_failed_pwd_wrong"
        },
        method = RequestMethod.GET
    )
    public ModelAndView infoEditFailedPwdWrong(ModelAndView modelAndView, HttpServletRequest request) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "信息修改失败");
        modelAndView.addObject("info", "原密码输入错误，请重新输入");
        if (request.getSession().getAttribute("role").toString().equals("admin")) {
            modelAndView.addObject("returnLink", "/admin/myinfo_page");
        } else if (request.getSession().getAttribute("role").toString().equals("leader")) {
            modelAndView.addObject("returnLink", "/leader/myinfo_page");
        } else if (request.getSession().getAttribute("role").toString().equals("volunteer")) {
            modelAndView.addObject("returnLink", "/volunteer/myinfo_page");
        }
        modelAndView.addObject("returnButtonText", "返回个人信息页面");
        return modelAndView;
    }

    @RequestMapping(value = { 
            "admin/message/info_edit_success",
            "leader/message/info_edit_success",
            "volunteer/message/info_edit_success" 
        },
        method = RequestMethod.GET
    )
    public ModelAndView infoEditSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "信息修改成功");
        modelAndView.addObject("returnLink", "/logout");
        modelAndView.addObject("returnButtonText", "前往登录页重新登录");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/create_user_failed_unknow_role", method = RequestMethod.GET)
    public ModelAndView createUserFailedUnknowRole(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "创建用户失败");
        modelAndView.addObject("info", "未知用户角色，请检查您的角色选择");
        modelAndView.addObject("returnLink", "/admin/user_create_page");
        modelAndView.addObject("returnButtonText", "返回创建用户页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/create_user_failed", method = RequestMethod.GET)
    public ModelAndView createUserFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "创建用户失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_create_page");
        modelAndView.addObject("returnButtonText", "返回创建用户页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/create_user_success", method = RequestMethod.GET)
    public ModelAndView createUserSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "创建用户成功");
        modelAndView.addObject("returnLink", "admin/welcome");
        modelAndView.addObject("returnButtonText", "返回主页");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/volunteer_info_reset_failed", method = RequestMethod.GET)
    public ModelAndView volunteerInfoFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "志愿者信息重置失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "/admin/message/volunteer_info_reset_success", method = RequestMethod.GET)
    public ModelAndView volunteerInfoSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "志愿者信息重置成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/leader_info_reset_failed", method = RequestMethod.GET)
    public ModelAndView leaderInfoFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "负责人信息重置失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "/admin/message/leader_info_reset_success", method = RequestMethod.GET)
    public ModelAndView leaderInfoSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "负责人信息重置成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }


    @RequestMapping(path = "admin/warning/leader_pwd_reset_failed", method = RequestMethod.GET)
    public ModelAndView leaderPwdResetFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "负责人密码重置失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/message/leader_pwd_reset_success", method = RequestMethod.GET)
    public ModelAndView leaderPwdResetSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "负责人密码重置成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/volunteer_pwd_reset_failed", method = RequestMethod.GET)
    public ModelAndView volunteerPwdResetFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "志愿者密码重置失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/message/volunteer_pwd_reset_success", method = RequestMethod.GET)
    public ModelAndView volunteerPwdResetSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "志愿者密码重置成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/volunteer_delete_failed", method = RequestMethod.GET)
    public ModelAndView volunteerDeleteFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "志愿者删除失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "/admin/message/volunteer_delete_success", method = RequestMethod.GET)
    public ModelAndView volunteerDeleteSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "志愿者删除成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/volunteer");
        modelAndView.addObject("returnButtonText", "返回志愿者管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/leader_delete_failed", method = RequestMethod.GET)
    public ModelAndView leaderDeleteFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "负责人删除失败");
        modelAndView.addObject(
            "info", 
            "请稍后重新尝试，或联系技术人员" +
            "</h4><br /><p>您可以尝试手动删除该负责人所负责的所有活动，然后再删除该负责人，如果执行该方法后仍然无法删除，请联系技术人员</p>"
        );
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "/admin/message/leader_delete_success", method = RequestMethod.GET)
    public ModelAndView leaderDeleteSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "负责人删除成功");
        modelAndView.addObject("returnLink", "/admin/user_manager/leader");
        modelAndView.addObject("returnButtonText", "返回负责人管理页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/actvity_create_error", method = RequestMethod.GET)
    public ModelAndView activityCreateError(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "活动创建失败");
        modelAndView.addObject("info", "请正确设置时间，不要出现时间段重叠，如有疑问请联系技术人员");
        modelAndView.addObject("returnLink", "/admin/create_activity_page");
        modelAndView.addObject("returnButtonText", "返回活动创建页面");
        return modelAndView;
    }

    @RequestMapping(path = "admin/warning/actvity_create_failed", method = RequestMethod.GET)
    public ModelAndView activityDeleteFailed(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/failed");
        modelAndView.addObject("context", "活动删除失败");
        modelAndView.addObject("info", "请稍后重新尝试，或联系技术人员");
        modelAndView.addObject("returnLink", "/admin/activities_list_page");
        modelAndView.addObject("returnButtonText", "返回活动列表页面");
        return modelAndView;
    }

    @RequestMapping(path = "/admin/message/actvity_create_success", method = RequestMethod.GET)
    public ModelAndView activityCreateSuccess(ModelAndView modelAndView) {
        modelAndView.setViewName("op_result/success");
        modelAndView.addObject("context", "活动创建成功");
        modelAndView.addObject("returnLink", "/admin/activities_list_page");
        modelAndView.addObject("returnButtonText", "返回活动列表页面");
        return modelAndView;
    }
    
}
